package com.zoffy.codesandbox.controller;


import com.zoffy.codesandbox.CodeSandbox;
import com.zoffy.codesandbox.JavaCodeSandbox;
import com.zoffy.codesandbox.model.ExecuteCodeRequest;
import com.zoffy.codesandbox.model.ExecuteCodeResponse;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class MainController {
    @Resource
    private CodeSandbox javaCodeSandbox;
    @GetMapping()
    public String checkHealth() {
        return "ok";
    }
    @PostMapping("/execute")
    public ExecuteCodeResponse executeCode(@RequestBody ExecuteCodeRequest executeCodeRequest){
        ExecuteCodeResponse executeCodeResponse = javaCodeSandbox.executeCode(executeCodeRequest);
        return executeCodeResponse;
    }

}
